<template>
	<view class="content">
		<view class="record-list" v-if="orderList.length>0">
			<view class="record_item" v-for="(item,index) in orderList" :key="index">
				<view class="time">{{item.createTime}}</view>
				<view class="br"></view>
        <view class="name">{{item.stationName}} <!-- <text>(特来电都江堰倾城桥充电站)</text> --> </view>
				<view class="record_info">
					<view class="left">加油升数</view>
					<view class="right">{{item.vol}}升</view>
				</view>
				<view class="record_info">
					<view class="left">{{item.prName}}单价</view>
					<view class="right">{{item.price}}元/升</view>
				</view>
				<view class="record_info">
					<view class="left">订单金额</view>
					<view class="right item-price">￥{{item.fuelAmt}}</view>
				</view>
				<view class="record_info">
					<view class="left">优惠金额</view>
					<view class="right item-price">-￥{{item.discAmt}}</view>
				</view>
				<view class="record_info real-pay">
					<view class="left">实付金额</view>
          <view class="right item-price"><text>{{item.realAmt}}</text>元</view>
				</view>
			</view>
		</view>
    <empty v-else></empty>
	</view>
</template>

<script>
	import {
		fuelOrders
	} from '@/api/index'
	import {
		toast
	} from '../../../utils/common';
  import empty from "@/components/empty.vue";
	export default {
    components: {empty},
		data() {
			return {
				openId: uni.getStorageSync('userOpenId'),
				orderList: [], //订单列表
				totalPage: 0,
				pageNum: 1,
				pageSize: 10
			};
		},
		onLoad() {
			this.getfuelOrder()
		},
		onPullDownRefresh() {
			this.pageNum = 1;
			this.orderList = [];
			this.getfuelOrder();
		},
		onReachBottom() {
			if (this.pageNum < this.totalPage) {
				this.pageNum += 1;
				this.getfuelOrder();
				return;
			}
			toast('没有更新的数据啦...')
		},
		methods: {
			getfuelOrder() {
				fuelOrders({
					openid: this.openId,
					paidStatus: 1,
					pageNum: this.pageNum,
					pageSize: this.pageSize
				}).then(res => {
					if (res.rows.length > 0) {
						// this.orderList = res.rows
						this.orderList = this.orderList.concat(res.rows)
						this.totalPage = res.totalPage
						return
					}
					this.orderList = []
					this.totalPage = 0
				}).catch(error => {
					this.orderList = []
					this.totalPage = 0
					console.log(error)
				})
			},
		}
	};
</script>

<style lang="scss" scope>
	.content {
		.record-list {
			padding: 24rpx 24rpx 24rpx 24rpx;

			.record_item {
				padding: 0 0 24rpx;
				background: #ffffff;
				box-shadow: 0px 0px 20rpx 0px rgba(135, 165, 216, 0.1);
				border-radius: 16rpx;
				margin-bottom: 24rpx;

				.name {
					font-size: 34rpx;
					color: #2d2b2a;
					line-height: 84rpx;
          padding: 0 20upx;
          font-weight: 500;
					//margin-bottom: 8rpx;

					text {
						font-size: 28rpx;
						color: #2d2b2a;
					}
				}

				.time {
					font-size: 28rpx;
					color: #1B1B1B;
					line-height: 92rpx;
          padding: 0 20upx;
				}

				.br {
					width: 100%;
					height: 1px;
					// border: 1px solid ;
					background-color: #ededed;
				}

				.record_info {
					display: flex;
					align-items: center;
					justify-content: space-between;
          padding: 0 20upx;

					.left {
						font-size: 28rpx;
						color: #6A6A6A;
            line-height: 84rpx;
					}

					.right {
						font-size: 28rpx;
            line-height: 84rpx;
						color: #1B1B1B;
					}

          .item-price{
            color: #F57546;
          }
				}

        .real-pay{
          font-weight: 500;
          .left{
            color: #1B1B1B;
          }
          .item-price{
            text{
              margin-right: 8upx;
              font-size: 44upx;
            }
          }
        }
			}

			.record_item:nth-last-child(1) {
				margin-bottom: 0;
			}
		}

		.hint {
			width: 100%;
			height: 100vh;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 42rpx;
			color: #c0c0c0;
			letter-spacing: 10rpx;
		}
	}
</style>